package com.finance.system.controller;

import com.finance.framework.controller.BaseController;
import com.finance.framework.controller.Result;
import com.finance.framework.lang.Page;
import com.finance.framework.lang.PageResultBO;
import com.finance.system.bean.pojo.Warehouse;
import com.finance.system.bean.pojo.WarehouseList;
import com.finance.system.request.WarehouseListReq;
import com.finance.system.service.IWarehouseService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.List;

/**
 * 承运商管理
 * @Author: gyw
 * @Date: Created in 2017-09-20
 */
@Controller
@RequestMapping("/system/warehouse")
public class WarehouseController extends BaseController{
    @Resource
    private IWarehouseService warehouseService;

    /**
     * 发货仓管理
     * @return
     */
    @RequestMapping("/index.htm")
    public String index(){
        return "system/warehouse/index";
    }


    /**
     * 分页查询
     *
     * @param form
     * @return
     */
    @RequestMapping("/list")
    public Result list(WarehouseListReq form) {
        Page page = Page.getInstance(form);
        WarehouseList warehouseList = new WarehouseList();
        warehouseList.setWarehouseCode(form.getWarehouseCode());
        warehouseList.setWarehouseName(form.getWarehouseName());
        warehouseList.setProvinceCode(form.getProvinceCode());
        warehouseList.setCityCode(form.getCityCode());
        warehouseList.setCountyCode(form.getCountyCode());
        page.setParams(warehouseList);
        PageResultBO<Warehouse> pageResultBO = warehouseService.listByPage(page);
        return getSuccessResult(pageResultBO);

    }

    /**
     * 发货仓列表
     * @return
     */
    @RequestMapping("/listall")
    public Result listAll(){
        List<Warehouse> warehouseList = warehouseService.listAll();
        return getSuccessResult(warehouseList);
    }

}
